package com.example.controller;

import com.example.common.Result;
import com.example.constant.PathConstant;
import com.example.entity.User;
import com.example.service.ReIDService;
import com.example.service.UserService;
import com.example.utils.FalskClient;
import com.example.utils.PythonExecuteUtil;
import com.example.utils.tempFileUtil;
import jakarta.annotation.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;


@RestController
public class WebController {

    @Resource
    private UserService userService;


    /**
     * 默认请求接口
     */
    @GetMapping("/")
    public Result hello() {
        return Result.success();
    }

    /**
     * 登录
     */
    @PostMapping("/login")
    public Result login(@RequestBody User user) {
        User ac = null;
        ac = userService.login(user);
        return Result.success(ac);
    }

    /**
     * 注册
     */
    @PostMapping("/register")
    public Result register(@RequestBody User user) {
        userService.registerForUser(user);
        Result.success().setMsg("注册成功");
        return Result.success();
    }

    /**
     * 修改密码
     */
    @PutMapping("/updatePassword")
    public Result updatePassword(@RequestBody User user) {
        userService.updatePassword(user);
        return Result.success();
    }

    @Resource
    ReIDService reIDService;

    @PostMapping("/test")
    public Result test(@RequestParam("file") MultipartFile file,@RequestParam("uid") String uid) throws IOException {
        reIDService.Person_ReID_Identification(file, uid);
        return Result.success();
    }
}
